package com.nopay.cdxphone.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nopay.cdxphone.R;

public class CallDelaySettingAdapter extends BaseAdapter {

    private final int[] DELAY_ARRAY = {3, 5, 10, 20, 30, 50};

    private final LayoutInflater mInflater;

    public CallDelaySettingAdapter(Context context) {
        super();
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return DELAY_ARRAY.length;
    }

    @Override
    public Integer getItem(int position) {
        return DELAY_ARRAY[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_call_delay_setting, null);
            holder.tv_delay = convertView.findViewById(R.id.tv_delay);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tv_delay.setText(getItem(position) + "秒");
        return convertView;
    }

    public static class ViewHolder {
        private TextView tv_delay;
    }
}
